<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="crm.model.Employees"%>
<%@page import="crm.control.EmployeesControl"%>
<%@page import="crm.control.SaleareaControl"%>
<%@page import="crm.util.GetBaseParam"%>
<%@page import="java.util.*"%>
<%@page import="crm.util.ParamUtil"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- validation -->
<link href="../../../resources/validation/css/formitem.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../../resources/validation/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../../../resources/validation/jquery.form-1.0.1.js"></script>
<script type="text/javascript" src="../../../resources/validation/jquery.form.valid-1.0.1.js"></script>
<script type="text/javascript">
$(function(){//跟顺序有关！按照form里面显示顺序排
			$("#username").username();
			$("#name").feikong();
			$("#userid").number();
			$("#password").password();
			$('#mobile').mobile();
			$('#phone').number();
			$('#email').email();
			$("form").find("input[type!='radio'][type!='checkbox'][type!='button'][type!='submit'][type!='reset']").each(function(){
				$(this).addClass("form_item_input");
			});
		});
</script>
<!-- end -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../resources/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../resources/css/inner.css" type="text/css" media="screen" />
<style type='text/css'>
 a{font-size:12px; text-decoration:none; color:#70B300;}
</style>
<script type="text/javascript" src="../../../resources/js/WebCalendar.js"></script>
<script type='text/javascript'>
	window.onload=function(){
		var ensure=document.getElementById("ensure");
		var pass = document.getElementById('password');
		var value = document.getElementById('checkpass').value;
		ensure.style.display  = 'none';
		pass.onkeyup=function(){
			ensure.style.display  = '';
			value = '';
		}
		var form = document.getElementById('form');
		form.onsubmit=function(){
			var t = new Check('password','checkpass');
			var m=t.falg;
			return m;
		}
		var pass=document.getElementById('checkpass');
		pass.onkeyup = function(){
		new Check('password','checkpass');
		}
	}
	function Check(pass1,pass2){
		this.pass1=document.getElementById(pass1);
		this.pass2=document.getElementById(pass2);
		this.falg=false;
		if(this.pass1.value == this.pass2.value){
			this.pass2.className = "form_item_input right-style";
			this.falg=true;
			return true;
		} else{
			this.pass2.className = "form_item_input error-style";
			this.pass2.focus();
			this.falg=false;
			return false;
		}
		return false;
	}
</script>
		<title>employees_update</title>
	</head>
	<body>
		<%
			request.setCharacterEncoding("UTF-8");
			Employees cu =(Employees)session.getAttribute("user");
			// int id = Integer.parseInt(request.getParameter("id"));
			int id = ParamUtil.getInt(request,"id",cu.getId());
			Employees employees = new Employees();
			employees = EmployeesControl.getEmpolyeesById(id);
			//Employees cu=(Employees)session.getAttribute("user");
		%>
		<form id='form' action="employees_update_do.jsp?id=<%=id %>" method="post">
			<table>
				<tr>
					<td>
						姓名
					</td>
					<td>
						<input type="text" required="true"  valid='feikong' name="name" id='name' value="<%=employees.getName()%>" />
					</td>
				</tr>
				<tr>
					<td>
						身份证号
					</td>
					<td>
						<input type="text" name="idcard" id='userid' required="true"  valid='number'
							value="<%=employees.getIdcard()%>" />
					</td>
				</tr>
				<tr>
					<td>
						性别
					</td>
					<td>
						<input type="radio" name="gender" value="1"
							<%if (employees.getGender() != null
					&& employees.getGender().equals("1"))
				out.print("checked");%> />
						男
						<input type="radio" name="gender" value="0"
							<%if (employees.getGender() != null
					&& employees.getGender().equals("0"))
				out.print("checked");%> />
						女
					</td>
				</tr>
				<tr>
					<td>
						出生年月
					</td>
					<td>
						<input type="text" name="birthday" maxlength="20" id='birthday'
							onClick="SelectDate(this,'yyyy-MM-dd')"
							value="<%=employees.getBirthday()%>" readonly/>
					</td>
				</tr>
				<tr>
					<td>
						民族
					</td>
					<td>
						<select name="nation">
							<%
								HashMap nations = GetBaseParam.getAllNations();
								Iterator it1 = nations.entrySet().iterator();
								while (it1.hasNext()) {
									Map.Entry entry = (Map.Entry) it1.next();
							%>
							<option value="<%=entry.getKey()%>"
								<%if (employees.getNation() == Integer.parseInt(entry.getKey()
						+ ""))
					out.print("selected='selected'");%>><%=entry.getValue()%></option>
							<%
								}
							%>
						</select>
					</td>
				</tr>

				<tr>
					<td>
						生源类别
					</td>
					<td>
						<input type="radio" name="home_type" value="0"
							<%if (employees.getHome_type() != null
					&& employees.getHome_type().equals("0"))
				out.print("checked");%> />
						农村
						<input type="radio" name="home_type" value="1"
							<%if (employees.getHome_type() != null
					&& employees.getHome_type().equals("1"))
				out.print("checked");%> />
						城市
					</td>
				</tr>
				<tr>
					<td>
						政治面貌
					</td>
					<td>
						<select name="polity" >
							<%
								HashMap politys = GetBaseParam.getAllPolities();
								Iterator it2 = politys.entrySet().iterator();
								while (it2.hasNext()) {
									Map.Entry entry = (Map.Entry) it2.next();
							%>
							<option value="<%=entry.getKey()%>"
								<%if (employees.getPolity() == Integer.parseInt(entry.getKey()
						+ ""))
					out.print("selected='selected'");%>><%=entry.getValue()%></option>
							<%
								}
							%>
						</select>
					</td>
				</tr>
				<tr>
					<td>
						婚否
					</td>
					<td>
						<input type="radio" name="is_married" value="1"
							<%if (employees.getIs_married() != null
					&& employees.getIs_married().equals("1"))
				out.print("checked");%> />
						已婚
						<input type="radio" name="is_married" value="0"
							<%if (employees.getIs_married() != null
					&& employees.getIs_married().equals("0"))
				out.print("checked");%> />
						未婚
					</td>
				</tr>
				<!-- tr>
					<td>
						子女生日
					</td>
					<td>
						<input type="text" name="baby_birth" maxlength="20"
							onClick="SelectDate(this,'yyyy-MM-dd')"
							value="" readonly/>
					</td>
				</tr> -->
				<tr>
					<td>
						用户名
					</td>
					<td>
						<input type="text" name="username" id='username' 
							value="<%=employees.getUsername()%>" readonly/>
					</td>
				</tr>
				<tr>
					<td>
						密码
					</td>
					<td>
						<input id='password' type="text" name="password" id='password' required="true" valid='password'
							value='<%=employees.getPassword()%>' />
					</td>
				</tr>
				<tr id='ensure'>
				    <td>
				    确认密码
				    </td>
				    <td>
				    <input id='checkpass' type='text' value='<%=employees.getPassword()%>'/>
				    </td>
				</tr>
						<%if(cu.getPosition()!=1){ %>	
				<tr>
					<td>
						职务
					</td>
					<td>
						<select name="position">
							<%
								HashMap positions = GetBaseParam.getAllPostions();
								Iterator it3 = positions.entrySet().iterator();
								while (it3.hasNext()) {
									Map.Entry entry = (Map.Entry) it3.next();
							%>
							<option value="<%=entry.getKey()%>"
								<%if (employees.getPosition() == Integer.parseInt(entry.getKey()
						+ ""))
					out.print("selected='selected'");%>><%=entry.getValue()%></option>
							<%
								}
							%>
						</select>
					</td>
				</tr>
				<%} %>
				<tr>
					<td>
						入职时间
					</td>
					<td>
						<input type="text" name="start_time" maxlength="20"
							onClick="SelectDate(this,'yyyy-MM-dd')"
							value="<%=employees.getStart_time()%>" readonly/>
					</td>
				</tr>
				<tr>
					<td>
						所属区域
					</td>
					<td>
						<select name="area_id">
							<%
								HashMap areas = SaleareaControl.getAllSaleArea();
								Iterator it4 = areas.entrySet().iterator();
								while (it4.hasNext()) {
									Map.Entry entry = (Map.Entry) it4.next();
							%>
							<option value="<%=entry.getKey()%>"
								<%if (employees.getArea_id() == Integer.parseInt(entry.getKey()
						+ ""))
					out.print("selected='selected'");%>><%=entry.getValue()%></option>
							<%
								}
							%>
						</select>
					</td>
				</tr>
				<tr>
					<td>
						学历
					</td>
					<td>
						<select name="edu_level">
							<option value="小学"
								<%if (employees.getEdu_level().equals("小学"))
				out.print("selected='selected'");%>>
								小学
							</option>
							<option value="初中"
								<%if (employees.getEdu_level().equals("初中"))
				out.print("selected='selected'");%>>
								初中
							</option>
							<option value="高中"
								<%if (employees.getEdu_level().equals("高中"))
				out.print("selected='selected'");%>>
								高中
							</option>
							<option value="专科"
								<%if (employees.getEdu_level().equals("专科"))
				out.print("selected='selected'");%>>
								专科
							</option>
							<option value="本科"
								<%if (employees.getEdu_level().equals("本科"))
				out.print("selected='selected'");%>>
								本科
							</option>
							<option value="研究生"
								<%if (employees.getEdu_level().equals("研究生"))
				out.print("selected='selected'");%>>
								研究生
							</option>
							<option value="硕士"
								<%if (employees.getEdu_level().equals("硕士"))
				out.print("selected='selected'");%>>
								硕士
							</option>
							<option value="博士"
								<%if (employees.getEdu_level().equals("博士"))
				out.print("selected='selected'");%>>
								博士
							</option>
							<option value="博士后"
								<%if (employees.getEdu_level().equals("博士后"))
				out.print("selected='selected'");%>>
								博士后
							</option>
						</select>
					</td>
				</tr>
				<tr>
					<td>
						手机号
					</td>
					<td>
						<input type="text" name="cellphone" id='mobile' required='true' valid='mobile'
							value="<%=employees.getCellphone()%>" />
					</td>
				</tr>
				<tr>
					<td>
						固定电话
					</td>
					<td>
						<input id='phone' valid='number' type="text" name="phone" value="<%=employees.getPhone()%>" />
					</td>
				</tr>
				<tr>
					<td>
						Email
					</td>
					<td>
						<input id='email' valid='email' type="text" name="email" value=<%=employees.getEmail()%> />
					</td>
				</tr>

				<tr>
					<td>
						家庭住址
					</td>
					<td>
						<input id='address' type="text" name="family_address" value="<%=employees.getFamily_address()%>" />
					</td>
				</tr>
				<tr>
					<td style='text-align:center;' colspan='2'>
						<input class='button' id='submit' type="submit" value="提交" />
					</td>
				</tr>
			</table>
			<br/>
			<br/>
			<br/>
			<br/>
		</form>
	</body>
</html>